package com.UI
{
	import com.*;
	import com.Engine.*;
	import com.Packet.*;
	
	import flash.display.*;
	import flash.events.*;
	import flash.external.*;
	import flash.filters.*;
	import flash.geom.*;
	import flash.system.*;
	import flash.text.*;
	import flash.ui.*;
	import flash.utils.*;
	
	import gs.*;
	import gs.easing.*;
	import gs.events.TweenEvent;
	
	import org.aswing.*;
	import org.aswing.border.*;
	import org.aswing.border.EmptyBorder;
	import org.aswing.colorchooser.*;
	import org.aswing.dnd.*;
	import org.aswing.event.*;
	import org.aswing.ext.*;
	import org.aswing.geom.*;
	import org.aswing.tree.AbstractLayoutCache;
	
	public class FrameSlave extends JFrame
	{
		//members define
		private var panel8:JPanel;
		private var panel12:JPanel;
		private var btn_slave_tab_slave:JToggleButton;
		private var btn_slave_tab_master:JToggleButton;
		private var btn_slave_tab_catch:JToggleButton;
		private var panelBottom:JPanel;
		
		//----------------------------------
		private var btn_close:JButton;
		
		public var panelBottomMaster:PaneSlaveMaster;
		public var panelBottomCatch:PaneSlaveCatch;
		public var panelBottomSlave:PaneSlaveSlave;
		public function FrameSlave()
		{
			setClosable(false);
			setResizable(false);  
			setBorder(new EmptyBorder());
			
			btn_close = new JButton();
			btn_close.setLocation(new IntPoint(82, 0));
			btn_close.setSize(new IntDimension(27, 27));
			btn_close.setPreferredSize(new IntDimension(27, 27));
			this.getTitleBar().setCloseButton(btn_close);
			this.getTitleBar().setMinimizeHeight(32);
			
			//component creation
			setSize(new IntDimension(370, 396));
			setPreferredSize(new IntDimension(370, 396));
			var layout0:EmptyLayout = new EmptyLayout();
			getContentPane().setLayout(layout0);
			
			panel8 = new JPanel();
			panel8.setLocation(new IntPoint(0, 0));
			panel8.setSize(new IntDimension(370, 33));
			panel8.setPreferredSize(new IntDimension(370, 33));
			var layout1:FlowWrapLayout = new FlowWrapLayout();
			layout1.setPreferWidth(200);
			layout1.setAlignment(AsWingConstants.LEFT);
			layout1.setHgap(20);
			layout1.setVgap(4);
			layout1.setMargin(true);
			panel8.setLayout(layout1);
			
			panel12 = new JPanel();
			panel12.setLocation(new IntPoint(20, 4));
			panel12.setSize(new IntDimension(132, 25));
			var layout2:SoftBoxLayout = new SoftBoxLayout();
			layout2.setAxis(AsWingConstants.HORIZONTAL);
			layout2.setAlign(AsWingConstants.LEFT);
			layout2.setGap(3);
			panel12.setLayout(layout2);
			
			btn_slave_tab_slave = new JToggleButton();
			btn_slave_tab_slave.setLocation(new IntPoint(5, 5));
			btn_slave_tab_slave.setSize(new IntDimension(72, 25));
			btn_slave_tab_slave.setPreferredSize(new IntDimension(72, 25));
			btn_slave_tab_slave.setText("label");
			
			btn_slave_tab_master = new JToggleButton();
			btn_slave_tab_master.setLocation(new IntPoint(59, 0));
			btn_slave_tab_master.setSize(new IntDimension(72, 25));
			btn_slave_tab_master.setPreferredSize(new IntDimension(72, 25));
			btn_slave_tab_master.setText("label");
			
			btn_slave_tab_catch = new JToggleButton();
			btn_slave_tab_catch.setLocation(new IntPoint(98, 4));
			btn_slave_tab_catch.setSize(new IntDimension(73, 25));
			btn_slave_tab_catch.setPreferredSize(new IntDimension(73, 25));
			btn_slave_tab_catch.setText("label");
			
			//panelBottom = new JPanel();
			//panelBottom.setLocation(new IntPoint(0, 33));
			//panelBottom.setSize(new IntDimension(370, 358));
			//panelBottom.setPreferredSize(new IntDimension(370, 358));
			
			//component layoution
			getContentPane().append(panel8);
			//append(panelBottom);
			
			panel8.append(panel12);
			
			panel12.append(btn_slave_tab_slave);
			panel12.append(btn_slave_tab_master);
			panel12.append(btn_slave_tab_catch);
			
			//---------------------------------------
			
			//private var panelBottomSlave:PaneSlaveSlave;
			//private var panelBottomCatch:PaneSlaveCatch;
			//private var panelBottomMaster:PaneSlaveMaster;
			
			panelBottomMaster = new PaneSlaveMaster();
			panelBottomMaster.setLocation(new IntPoint(0, 33));
			panelBottomMaster.setSize(new IntDimension(370, 358));
			panelBottomMaster.setPreferredSize(new IntDimension(370, 358));
			
			panelBottomCatch = new PaneSlaveCatch();
			panelBottomCatch.setLocation(new IntPoint(0, 33));
			panelBottomCatch.setSize(new IntDimension(370, 358));
			panelBottomCatch.setPreferredSize(new IntDimension(370, 358));
			
			panelBottomSlave = new PaneSlaveSlave();
			panelBottomSlave.setLocation(new IntPoint(0, 33));
			panelBottomSlave.setSize(new IntDimension(370, 358));
			panelBottomSlave.setPreferredSize(new IntDimension(370, 358));
			
			//panelBottom = panelBottomSlave;
			//getContentPane().append(panelBottom);
			panelBottom = null;
			setImages();
			this.setClipMasked(false);
			this.getContentPane().setClipMasked(false);
			//onTabSlave(null);
			//update();
		}
		private var img_slave_slave_bg:AssetBackground = null;
		private var img_slave_catch_bg:AssetBackground = null;
		
		public var img_slave_master_property_bg:AssetBackground = null;
		public var img_slave_master_skill_bg:AssetBackground = null;
		
		public function setImages():void
		{
			img_slave_slave_bg = new AssetBackground(Client.getUIElement("img_slave_slave_bg") as DisplayObject);
			img_slave_catch_bg = new AssetBackground(Client.getUIElement("img_slave_catch_bg") as DisplayObject);
			img_slave_master_property_bg = new AssetBackground(Client.getUIElement("img_slave_master_property_bg") as DisplayObject);
			img_slave_master_skill_bg = new AssetBackground(Client.getUIElement("img_slave_master_skill_bg") as DisplayObject);
			
			btn_close.wrapSimpleButton(Client.getUIElement("btn_close") as SimpleButton);
			btn_slave_tab_slave.wrapSimpleButton(Client.getUIElement("btn_4") as SimpleButton);
			btn_slave_tab_slave.setText("我的奴隶");
			btn_slave_tab_master.wrapSimpleButton(Client.getUIElement("btn_4") as SimpleButton);
			btn_slave_tab_master.setText("我的主人");
			btn_slave_tab_catch.wrapSimpleButton(Client.getUIElement("btn_4") as SimpleButton);
			btn_slave_tab_catch.setText("抓捕奴隶");
			var img_background:DisplayObject = img_slave_slave_bg.getDisplay(null);
			setBackgroundDecorator(img_slave_slave_bg);
			setSize(new IntDimension(img_background.width, img_background.height));
			setPreferredSize(new IntDimension(img_background.width, img_background.height));
			pack();
			setLocationXY((Engine.W - width) / 2,(Engine.H - height)/2);
			
			btn_slave_tab_slave.setHorizontalTextPosition(AsWingConstants.CENTER);
			btn_slave_tab_slave.setVerticalTextPosition(AsWingConstants.CENTER);
			btn_slave_tab_master.setHorizontalTextPosition(AsWingConstants.CENTER);
			btn_slave_tab_master.setVerticalTextPosition(AsWingConstants.CENTER);
			btn_slave_tab_catch.setHorizontalTextPosition(AsWingConstants.CENTER);
			btn_slave_tab_catch.setVerticalTextPosition(AsWingConstants.CENTER);

			btn_slave_tab_slave.setSelected(true);
			//btn_slave_tab_slave.wrapSimpleButton(Client.getUIElement("btn_slave_tab_slave") as SimpleButton);
			//btn_slave_tab_catch.wrapSimpleButton(Client.getUIElement("btn_slave_tab_catch") as SimpleButton);
			//btn_slave_tab_slave.setText("");
			//btn_slave_tab_catch.setText("");
			
			btn_slave_tab_slave.addActionListener(onTabSlave);
			btn_slave_tab_master.addActionListener(onTabMaster);
			btn_slave_tab_catch.addActionListener(onTabCatch);
			
			var group:ButtonGroup = new ButtonGroup();
			group.appendAll(btn_slave_tab_slave,btn_slave_tab_master,btn_slave_tab_catch);
			
			
			
			var filter:GlowFilter;
			var font:ASFont = new ASFont("宋体", 13, false, false, false, false);
			filter = new GlowFilter(0x000000, 1, 2, 2, 5);
			btn_slave_tab_slave.setFont(font);
			btn_slave_tab_master.setFont(font);
			btn_slave_tab_catch.setFont(font);
			btn_slave_tab_slave.setTextFilters(new Array(filter));
			btn_slave_tab_master.setTextFilters(new Array(filter));
			btn_slave_tab_catch.setTextFilters(new Array(filter));
			//labelName.setFont(font);
			//labelName.setForeground(ASColor.WHITE);
			//labelName.setTextFilters(new Array(filter));*/
			
		}
		private function onTabSlave(e:Event):void
		{
			btn_slave_tab_slave.setSelected(true);
			btn_slave_tab_catch.setSelected(false);
			btn_slave_tab_slave.setEnabled(true);
			//if(isMaster())
			//{
				if(panelBottomSlave.btn_slave_tab_property.isSelected() && getBackgroundDecorator() != img_slave_master_property_bg)
					setBackgroundDecorator(img_slave_master_property_bg);
				
				if(panelBottomSlave.btn_slave_tab_skill.isSelected() && getBackgroundDecorator() != img_slave_master_skill_bg)
					setBackgroundDecorator(img_slave_master_skill_bg);
				
				if(panelBottom != panelBottomSlave)
				{
					getContentPane().remove(panelBottom);
					panelBottom = panelBottomSlave;
					getContentPane().append(panelBottom);
				}
				panelBottomSlave.update();
			//}
			/*else if(isSlave())
			{
				if(getBackgroundDecorator() != img_slave_slave_bg)
					setBackgroundDecorator(img_slave_slave_bg);
				if(panelBottom != panelBottomSlave)
				{
					getContentPane().remove(panelBottom);
					panelBottom = panelBottomSlave;
					getContentPane().append(panelBottom);
				}
				panelBottomSlave.update();
			}
			else
			{
				btn_slave_tab_slave.setEnabled(false);
				btn_slave_tab_slave.setSelected(false);
				btn_slave_tab_catch.setSelected(true);
				onTabCatch(null);
			}*/
			paintImmediately();
		}
		
		private function onTabMaster(e:Event):void
		{
			if(getBackgroundDecorator() != img_slave_slave_bg)
				setBackgroundDecorator(img_slave_slave_bg);
			if(panelBottom != panelBottomMaster)
			{
				getContentPane().remove(panelBottom);
				panelBottom = panelBottomMaster;
				getContentPane().append(panelBottom);
			}
			panelBottomMaster.update();
		}
		private function onTabCatch(e:Event):void
		{
			if(getBackgroundDecorator() != img_slave_catch_bg)
				setBackgroundDecorator(img_slave_catch_bg);
			
			if(panelBottom != panelBottomCatch)
			{
				getContentPane().remove(panelBottom);
				panelBottom = panelBottomCatch;
				getContentPane().append(panelBottom);
				panelBottomCatch.update();
			}
			paintImmediately();
		}
		
		public function hasMaster():Boolean
		{
			return int(CharInfo.m_nSlaveMasterCharId) != 0;//Const.SLAVE_STATUS_MASTER;
		}
		public function hasSlave():Boolean
		{
			return CharInfo.m_arSlaves.length != 0;//Const.SLAVE_STATUS_SLAVE;
		}
		
		public function update():void
		{
			btn_slave_tab_slave.setEnabled(hasSlave());
			btn_slave_tab_master.setEnabled(hasMaster());
			
			if(panelBottom == panelBottomSlave && !hasSlave())
			{
				btn_slave_tab_slave.setSelected(false);
				btn_slave_tab_master.setSelected(true);
				btn_slave_tab_catch.setSelected(false);
				onTabMaster(null);
			}
			
			if(panelBottom == panelBottomMaster && !hasMaster())
			{
				btn_slave_tab_slave.setSelected(false);
				btn_slave_tab_master.setSelected(false);
				btn_slave_tab_catch.setSelected(true);
				onTabCatch(null);
			}
			
			if(panelBottom == panelBottomSlave)
				panelBottomSlave.update();
			if(panelBottom == panelBottomMaster)
				panelBottomMaster.update();
			if(panelBottom == panelBottomCatch)
				panelBottomCatch.update();
		}
		public function updateRefresh():void
		{
			panelBottomCatch.updateRefresh();
		}
		public static function phSlaves_1500(e:PacketEvent):void
		{
			var msg:Array = e.data as Array;
			trace("phSlaves_1500", msg);
			var nIndex:uint = 0;
			CharInfo.m_nSlaveMasterCharId = msg[nIndex++];
			CharInfo.m_nSlaveMasterCharName = msg[nIndex++];
			CharInfo.m_nSlaveMasterRace = msg[nIndex++];
			CharInfo.m_nSlaveMasterGender = msg[nIndex++];
			CharInfo.m_nSlaveMasterLevel = msg[nIndex++];
			
			var nCount:uint = msg[nIndex++];
			CharInfo.m_nSlaveJoinBattleIndex = msg[nIndex++];
			var array:Array = CharInfo.m_arSlaves;
			array.splice(0,array.length);
			for(var i:int = 0; i < nCount; i++)
			{
				var obj:Object = new Object();
				array[i] = obj;
				obj.index = i;
				obj.id = msg[nIndex++];
				obj.m_nInnerId = msg[nIndex++];
				obj.m_nCharId = msg[nIndex++];
				obj.m_szCharName = msg[nIndex++];
				obj.m_nRace = msg[nIndex++];
				obj.m_nGender = msg[nIndex++];
				obj.m_nLevel = msg[nIndex++];
				
				obj.m_nHP = msg[nIndex++];
				obj.m_nAP = msg[nIndex++];
				obj.m_nDP = msg[nIndex++];
				obj.m_nSP = msg[nIndex++];
				
				obj.m_nResistHL = msg[nIndex++];
				obj.m_nResistBD = msg[nIndex++];
				obj.m_nResistHS = msg[nIndex++];
				
				obj.m_nPropBJ = msg[nIndex++];
				obj.m_nPropSB = msg[nIndex++];
				obj.m_nPropFJ = msg[nIndex++];
				obj.m_nPropLJ = msg[nIndex++];
				
				obj.m_arEquips = new Array();
				var nEquips:uint = msg[nIndex++];
				for(j = 0; j < nEquips; j++)
				{
					obj.m_arEquips[j] =  msg[nIndex++];
				}
				
				obj.m_arSkills = new Array();
				var nSkills:uint = msg[nIndex++];
				for(var j:int = 0; j < nSkills; j++)
				{
					var objSkill:Object = new Object();
					objSkill.csv_id = msg[nIndex++];
					objSkill.m_nLevel = msg[nIndex++];
					obj.m_arSkills[j] = objSkill;
				}
				
				obj.m_nBattleMode = msg[nIndex++];
				obj.m_arAutoBattleSkills = [];
				for(var k:int = 0; k < 6; k++)
					obj.m_arAutoBattleSkills[k] = msg[nIndex++];
				obj.m_arAutoBattleSkillsSoul = [];
				for(k = 0; k < 6; k++)
					obj.m_arAutoBattleSkillsSoul[k] = msg[nIndex++];

				obj.m_arDefaultSkills = [];
				for(k = 0; k < Const.DEFAULT_SKILL_SIZE; k++)
					obj.m_arDefaultSkills[k] = msg[nIndex++];
			}
			
			if(FrameSlave.isShowing())
			{
				FrameSlave._frame.update();
			}
			PanelMainHelp.getInstance().onPartnerInfoUpdate();
			if(FrameBattleSetting.isShowing())
				FrameBattleSetting._frame.update();
		}
		public static var m_nSlavesCatchRefreshTime:int = 0;
		public static function phSlavesCatch_1503(e:PacketEvent):void
		{
			var msg:Array = e.data as Array;
			trace("phSlavesCatch_1503", msg);
			var nIndex:uint = 0;
			m_nSlavesCatchRefreshTime = msg[nIndex++];
			var nCount:uint = msg[nIndex++];
			var array:Array = CharInfo.m_arSlavesCatch;
			array.splice(0,array.length);
			for(var i:int = 0; i < nCount; i++)
			{
				var obj:Object = new Object();
				array[i] = obj;
				obj.index = i;
				obj.m_nCharId = msg[nIndex++];
				obj.m_szCharName = msg[nIndex++];
				obj.m_nLevel = msg[nIndex++];
				obj.m_nRace = msg[nIndex++];
				obj.m_nGender = msg[nIndex++];
				obj.m_nValue = msg[nIndex++];
				
			}
			
			if(FrameSlave.isShowing())
			{
				FrameSlave._frame.update();
			}
			PanelMainHelp.getInstance().onPartnerInfoUpdate();
			
			if(_timeCatchUpdate == null)
			{
				_timeCatchUpdate = new Timer(1000);
				_timeCatchUpdate.addEventListener(TimerEvent.TIMER,function():void
				{
					FrameSlave.m_nSlavesCatchRefreshTime++;
					if(FrameSlave._frame != null)
					{
						FrameSlave._frame.updateRefresh();
						var nTime:int = 5*60-FrameSlave.m_nSlavesCatchRefreshTime;
						if(nTime <= 0)
							_timeCatchUpdate.stop();
					}
					
				});
			}
			if(!_timeCatchUpdate.running)
				_timeCatchUpdate.start();
		}
		
		static private var _timeCatchUpdate:Timer = null;
		
		public static var _frame:FrameSlave = null;
		public static function show():void
		{
			if(isShowing())
			{
				hide();
				return;
			}
			if(_frame == null)
			{
				_frame = new FrameSlave();
				PanelMainHelp.getInstance().addChild(_frame);
			}
			
			_frame.show();
			_frame.onTabSlave(null);
			_frame.update();
			PanelMainHelp.getInstance().bringToTop(_frame);
		}
		public static function hide():void
		{
			if(isShowing())_frame.hide();
		}
		public static function isShowing():Boolean
		{
			return(_frame != null&& _frame.isShowing());
		}
	}
}

import com.*;
import com.Engine.*;
import com.Packet.*;
import com.UI.*;

import flash.display.*;
import flash.events.*;
import flash.external.*;
import flash.filters.*;
import flash.geom.*;
import flash.system.*;
import flash.text.*;
import flash.ui.*;
import flash.utils.*;

import gs.*;
import gs.easing.*;
import gs.events.TweenEvent;

import org.aswing.*;
import org.aswing.border.*;
import org.aswing.border.EmptyBorder;
import org.aswing.colorchooser.*;
import org.aswing.dnd.*;
import org.aswing.event.*;
import org.aswing.ext.*;
import org.aswing.geom.*;
import org.aswing.tree.AbstractLayoutCache;

/**
 * MyPaneSlaveSlave
 */
class PaneSlaveMaster extends JPanel{
	
	//members define
	private var labelMessage:JLabel;
	private var panelHead:JPanel;
	private var labelName:JLabelButton;
	private var labelLove:JLabel;
	private var panel22:JPanel;
	private var btn_slave_slave_zkl:JButton;
	private var btn_slave_slave_bzx:JButton;
	private var btn_slave_slave_th:JButton;
	private var btn_slave_slave_pj:JButton;
	private var btn_slave_slave_zz:JButton;
	private var btn_slave_slave_wp:JButton;
	private var btn_slave_slave_fk:JButton;
	private var btn_slave_slave_qz:JButton;
	private var btn_slave_slave_ss:JButton;
	
	/**
	 * MyPaneSlaveSlave Constructor
	 */
	public function PaneSlaveMaster(){
		//component creation
		setSize(new IntDimension(370, 358));
		setPreferredSize(new IntDimension(370, 358));
		var layout0:EmptyLayout = new EmptyLayout();
		setLayout(layout0);
		
		labelMessage = new JLabel();
		labelMessage.setLocation(new IntPoint(17, 9));
		labelMessage.setSize(new IntDimension(173, 18));
		labelMessage.setPreferredSize(new IntDimension(173, 18));
		labelMessage.setText("你现在是谁谁谁的奴隶");
		
		panelHead = new JPanel();
		panelHead.setLocation(new IntPoint(228, 39));
		panelHead.setSize(new IntDimension(69, 69));
		panelHead.setPreferredSize(new IntDimension(69, 69));
		
		labelName = new JLabelButton();
		labelName.setLocation(new IntPoint(193, 112));
		labelName.setSize(new IntDimension(142, 18));
		labelName.setPreferredSize(new IntDimension(142, 18));
		labelName.setText("陶陶陶 Lv.54");
		
		labelLove = new JLabel();
		labelLove.setLocation(new IntPoint(233, 135));
		labelLove.setSize(new IntDimension(100, 18));
		labelLove.setPreferredSize(new IntDimension(100, 18));
		labelLove.setText("14567");
		
		panel22 = new JPanel();
		panel22.setLocation(new IntPoint(175, 183));
		panel22.setSize(new IntDimension(171, 78));
		panel22.setPreferredSize(new IntDimension(171, 78));
		var layout1:GridLayout = new GridLayout();
		layout1.setRows(3);
		layout1.setColumns(3);
		layout1.setHgap(3);
		layout1.setVgap(3);
		panel22.setLayout(layout1);
		
		btn_slave_slave_zkl = new JButton();
		btn_slave_slave_zkl.setSize(new IntDimension(171, 24));
		btn_slave_slave_zkl.setText("label");
		
		btn_slave_slave_bzx = new JButton();
		btn_slave_slave_bzx.setLocation(new IntPoint(0, 27));
		btn_slave_slave_bzx.setSize(new IntDimension(171, 24));
		btn_slave_slave_bzx.setText("label");
		
		btn_slave_slave_th = new JButton();
		btn_slave_slave_th.setLocation(new IntPoint(0, 54));
		btn_slave_slave_th.setSize(new IntDimension(171, 24));
		btn_slave_slave_th.setText("label");
		
		btn_slave_slave_pj = new JButton();
		btn_slave_slave_pj.setLocation(new IntPoint(87, 27));
		btn_slave_slave_pj.setSize(new IntDimension(84, 24));
		btn_slave_slave_pj.setText("label");
		
		btn_slave_slave_zz = new JButton();
		btn_slave_slave_zz.setLocation(new IntPoint(0, 54));
		btn_slave_slave_zz.setSize(new IntDimension(84, 24));
		btn_slave_slave_zz.setText("label");
		
		btn_slave_slave_wp = new JButton();
		btn_slave_slave_wp.setLocation(new IntPoint(87, 54));
		btn_slave_slave_wp.setSize(new IntDimension(84, 24));
		btn_slave_slave_wp.setText("label");
		
		btn_slave_slave_fk = new JButton();
		btn_slave_slave_fk.setLocation(new IntPoint(0, 54));
		btn_slave_slave_fk.setSize(new IntDimension(55, 24));
		btn_slave_slave_fk.setText("label");
		
		btn_slave_slave_qz = new JButton();
		btn_slave_slave_qz.setLocation(new IntPoint(58, 54));
		btn_slave_slave_qz.setSize(new IntDimension(55, 24));
		btn_slave_slave_qz.setText("label");
		
		btn_slave_slave_ss = new JButton();
		btn_slave_slave_ss.setLocation(new IntPoint(116, 54));
		btn_slave_slave_ss.setSize(new IntDimension(55, 24));
		btn_slave_slave_ss.setText("label");
		
		//component layoution
		append(labelMessage);
		append(panelHead);
		append(labelName);
		append(labelLove);
		append(panel22);
		
		panel22.append(btn_slave_slave_zkl);
		panel22.append(btn_slave_slave_bzx);
		panel22.append(btn_slave_slave_th);
		panel22.append(btn_slave_slave_pj);
		panel22.append(btn_slave_slave_zz);
		panel22.append(btn_slave_slave_wp);
		panel22.append(btn_slave_slave_fk);
		panel22.append(btn_slave_slave_qz);
		panel22.append(btn_slave_slave_ss);
		
		setImages();
	}
	
	public function setImages():void
	{
		

		btn_slave_slave_zkl.wrapSimpleButton(Client.getUIElement("btn_slave_slave_zkl") as SimpleButton);
		btn_slave_slave_zkl.setText("");
		btn_slave_slave_bzx.wrapSimpleButton(Client.getUIElement("btn_slave_slave_bzx") as SimpleButton);
		btn_slave_slave_bzx.setText("");
		btn_slave_slave_th.wrapSimpleButton(Client.getUIElement("btn_slave_slave_th") as SimpleButton);
		btn_slave_slave_th.setText("");
		btn_slave_slave_pj.wrapSimpleButton(Client.getUIElement("btn_slave_slave_pj") as SimpleButton);
		btn_slave_slave_pj.setText("");
		btn_slave_slave_zz.wrapSimpleButton(Client.getUIElement("btn_slave_slave_zz") as SimpleButton);
		btn_slave_slave_zz.setText("");
		btn_slave_slave_wp.wrapSimpleButton(Client.getUIElement("btn_slave_slave_wp") as SimpleButton);
		btn_slave_slave_wp.setText("");
		btn_slave_slave_fk.wrapSimpleButton(Client.getUIElement("btn_slave_slave_fk") as SimpleButton);
		btn_slave_slave_fk.setText("");
		btn_slave_slave_qz.wrapSimpleButton(Client.getUIElement("btn_slave_slave_qz") as SimpleButton);
		btn_slave_slave_qz.setText("");
		btn_slave_slave_ss.wrapSimpleButton(Client.getUIElement("btn_slave_slave_ss") as SimpleButton);
		btn_slave_slave_ss.setText("");
		
		btn_slave_slave_zkl.setEnabled(false);
		btn_slave_slave_bzx.setEnabled(false);
		btn_slave_slave_th.setEnabled(false);
		btn_slave_slave_pj.setEnabled(false);
		btn_slave_slave_zz.setEnabled(false);
		btn_slave_slave_wp.setEnabled(false);
		btn_slave_slave_fk.setEnabled(false);
		btn_slave_slave_qz.setEnabled(false);
		btn_slave_slave_ss.setEnabled(false);
		
		
		panelHead.setBackgroundDecorator(new AssetBackground(Client.getUIElement("img_head") as DisplayObject));
		
		var filter:GlowFilter;
		var font:ASFont = new ASFont("宋体", 13, false, false, false, false);
		filter = new GlowFilter(0x000000, 1, 2, 2, 10);
		
		labelMessage.setFont(font);
		labelMessage.setForeground(ASColor.WHITE);
		labelMessage.setTextFilters(new Array(filter));
		
		labelName.setFont(new ASFont("宋体", 13, false, false, true, false));
		labelName.setForeground(ASColor.WHITE);
		labelName.setTextFilters(new Array(filter));
		
		labelLove.setFont(font);
		labelLove.setForeground(ASColor.WHITE);
		labelLove.setTextFilters(new Array(filter));
		
		labelName.addActionListener(onBtnName);
		
	}
	private function onBtnName(e:Event):void
	{
		var obj:Object = new Object;
		obj.m_nCharId = int(CharInfo.m_nSlaveMasterCharId);
		obj.m_szCharName = CharInfo.m_nSlaveMasterCharName;
		obj.m_nLevel = int(CharInfo.m_nSlaveMasterLevel);
		obj.m_nRace = int(CharInfo.m_nSlaveMasterRace);
		obj.m_nGender = int(CharInfo.m_nSlaveMasterGender);
		
		var point:IntPoint = AsWingUtils.getStageMousePosition();
		FrameClickChar._objDest = obj;
		FrameClickChar._destCharId = int(obj.m_nCharId);
		FrameClickChar.show(FrameSlave._frame,point.x-FrameSlave._frame.x,point.y-FrameSlave._frame.y);
	}
	//_________getters_________
	
	public function update():void
	{
		//panelBottom.update();
		if(CharInfo.m_nSlaveMasterCharName.length == 0)
		{
			labelMessage.setText('你现在没有主人');
			labelName.setText('');
			labelLove.setText('');
			panelHead.setBackgroundDecorator(null);
		}
		else
		{
			labelMessage.setText('你现在是'+CharInfo.m_nSlaveMasterCharName+'的奴隶');
			labelName.setText(CharInfo.m_nSlaveMasterCharName + ' Lv.'+CharInfo.m_nSlaveMasterLevel);
			labelName.setForeground(new ASColor(CharInfo.m_nSlaveMasterGender == 0 ? Engine.colorBoy : Engine.colorGirl));
			labelLove.setText('');
			panelHead.setBackgroundDecorator(new AssetBackground(Client.getUIElement("img_head") as DisplayObject));
		}
	}
	
}

/**
 * MyPaneSlaveCatch
 */
class PaneSlaveCatch extends JPanel{
	
	//members define
	private var labelMessage:JLabel;
	private var panelItems:JPanel;
	private var labelRefresh:JLabel;
	private var btn_slave_catch_refresh:JButton;
	
	/**
	 * MyPaneSlaveCatch Constructor
	 */
	public function PaneSlaveCatch(){
		//component creation
		setSize(new IntDimension(370, 358));
		setPreferredSize(new IntDimension(370, 358));
		var layout0:EmptyLayout = new EmptyLayout();
		setLayout(layout0);
		
		labelMessage = new JLabel();
		labelMessage.setLocation(new IntPoint(17, 9));
		labelMessage.setSize(new IntDimension(186, 18));
		labelMessage.setPreferredSize(new IntDimension(186, 18));
		labelMessage.setText("你可以抓捕以下玩家:");
		
		panelItems = new JPanel();
		panelItems.setLocation(new IntPoint(21, 53));
		panelItems.setSize(new IntDimension(331, 235));
		panelItems.setPreferredSize(new IntDimension(331, 235));
		var layout1:GridLayout = new GridLayout();
		layout1.setRows(2);
		layout1.setColumns(2);
		layout1.setHgap(5);
		layout1.setVgap(5);
		panelItems.setLayout(layout1);
		
		labelRefresh = new JLabel();
		labelRefresh.setLocation(new IntPoint(78, 313));
		labelRefresh.setSize(new IntDimension(151, 18));
		labelRefresh.setPreferredSize(new IntDimension(151, 18));
		labelRefresh.setText("剩余刷新时间: 00:12:23");
		
		btn_slave_catch_refresh = new JButton();
		btn_slave_catch_refresh.setLocation(new IntPoint(251, 308));
		btn_slave_catch_refresh.setSize(new IntDimension(80, 32));
		btn_slave_catch_refresh.setPreferredSize(new IntDimension(80, 32));
		btn_slave_catch_refresh.setText("label");
		
		//component layoution
		append(labelMessage);
		append(panelItems);
		append(labelRefresh);
		append(btn_slave_catch_refresh);
		
		setImages();
	}
	
	public function setImages():void
	{
		btn_slave_catch_refresh.wrapSimpleButton(Client.getUIElement("btn_slave_catch_refresh") as SimpleButton);
		btn_slave_catch_refresh.setText("");
		btn_slave_catch_refresh.addActionListener(onBtnRefresh);
		//panelHead.setBackgroundDecorator(new AssetBackground(Client.getUIElement("img_head") as DisplayObject));
		
		var filter:GlowFilter;
		var font:ASFont = new ASFont("宋体", 13, false, false, false, false);
		filter = new GlowFilter(0x000000, 1, 2, 2, 10);
		
		labelMessage.setFont(font);
		labelMessage.setForeground(ASColor.WHITE);
		labelMessage.setTextFilters(new Array(filter));
		
		labelRefresh.setFont(font);
		labelRefresh.setForeground(ASColor.GREEN);
		labelRefresh.setTextFilters(new Array(filter));
		
		for(var i:int = 0; i < 4; i++)
		{
			var item:PaneSlaveCatchItem = new PaneSlaveCatchItem;
			panelItems.append(item);
			_mallItems.push(item);
		}
	}
	private function onBtnRefresh(e:Event):void
	{
		Client.getInstance().sendPacketLogic(1503,[int(0)]);
	}
	private var _mallItems:Array = new Array();
	
	public function update():void
	{
		for each(var obj:Object in _mallItems)
		{
			obj.item = null;
		}
		
		var nIndex:int = 0;
		for each(var item:Object in CharInfo.m_arSlavesCatch)
		{
			_mallItems[nIndex].item = item;
			nIndex++;
			if(nIndex >= 4)
				break;
		}
		updateRefresh();
	}
	
	public function updateRefresh():void
	{
		if(!FrameSlave.isShowing())
			return;
		var nTime:int = 5*60-FrameSlave.m_nSlavesCatchRefreshTime;
		if(nTime > 0)
		{
			labelRefresh.setText("剩余刷新时间: "+PanelMainHelp.formatTime(5*60-FrameSlave.m_nSlavesCatchRefreshTime));
			btn_slave_catch_refresh.setEnabled(false);
		}
		else
		{
			labelRefresh.setText("现在可以立即刷新列表");
			btn_slave_catch_refresh.setEnabled(true);
		}
	}
	
}

/**
 * MyPaneSlaveCatchItem
 */
class PaneSlaveCatchItem extends JPanel{
	
	//members define
	private var btn_slave_catch_challenge:JButton;
	private var labelName:JLabelButton;
	private var labelLevel:JLabel;
	private var panelHead:JPanel;
	private var labelRace:JLabel;
	/**
	 * MyPaneSlaveCatchItem Constructor
	 */
	public function PaneSlaveCatchItem(){
		//component creation
		setSize(new IntDimension(163, 115));
		setPreferredSize(new IntDimension(163, 115));
		var layout0:EmptyLayout = new EmptyLayout();
		setLayout(layout0);
		
		btn_slave_catch_challenge = new JButton();
		btn_slave_catch_challenge.setLocation(new IntPoint(53, 85));
		btn_slave_catch_challenge.setSize(new IntDimension(57, 30));
		btn_slave_catch_challenge.setPreferredSize(new IntDimension(57, 30));
		btn_slave_catch_challenge.setText("label");
		
		labelName = new JLabelButton();
		labelName.setLocation(new IntPoint(75, 6));
		labelName.setSize(new IntDimension(86, 20));
		labelName.setPreferredSize(new IntDimension(86, 20));
		labelName.setText("陶陶陶");
		
		labelLevel = new JLabel();
		labelLevel.setLocation(new IntPoint(75, 31));
		labelLevel.setSize(new IntDimension(86, 20));
		labelLevel.setPreferredSize(new IntDimension(86, 20));
		labelLevel.setText("Lv.55");
		
		panelHead = new JPanel();
		panelHead.setLocation(new IntPoint(5, 5));
		panelHead.setSize(new IntDimension(69, 69));
		panelHead.setPreferredSize(new IntDimension(69, 69));
		
		labelRace = new JLabel();
		labelRace.setLocation(new IntPoint(75, 56));
		labelRace.setSize(new IntDimension(86, 20));
		labelRace.setPreferredSize(new IntDimension(86, 20));
		labelRace.setText("主人");
		
		//component layoution
		append(btn_slave_catch_challenge);
		append(labelName);
		append(labelLevel);
		append(panelHead);
		append(labelRace);
		
		setImages();
	}
	
	public function setImages():void
	{
		setBackgroundDecorator(new AssetBackground(Client.getUIElement("img_slave_catch_item_bg") as DisplayObject));
		
		btn_slave_catch_challenge.wrapSimpleButton(Client.getUIElement("btn_slave_catch_challenge") as SimpleButton);
		btn_slave_catch_challenge.setText("");
		btn_slave_catch_challenge.addActionListener(onBtnChallenge);
		panelHead.setBackgroundDecorator(new AssetBackground(Client.getUIElement("img_head") as DisplayObject));
		
		var filter:GlowFilter;
		var font:ASFont = new ASFont("宋体", 13, false, false, false, false);
		filter = new GlowFilter(0x000000, 1, 2, 2, 10);
		
		labelLevel.setFont(font);
		labelLevel.setForeground(ASColor.WHITE);
		labelLevel.setTextFilters(new Array(filter));
		
		labelRace.setFont(font);
		labelRace.setForeground(ASColor.WHITE);
		labelRace.setTextFilters(new Array(filter));
		
		labelName.setForeground(ASColor.GREEN);
		labelName.setMideground(ASColor.RED);
		labelName.setTextFilters(new Array(filter));
		labelName.setFont(new ASFont("宋体", 13, false, false, true, false));
		labelName.setBackground(ASColor.GRAY);
		
		labelName.addActionListener(onBtnName);
	}
	private function onBtnName(e:Event):void
	{
		if(_item == null)
		{
			return;
		}
		var obj:Object = new Object;
		obj.m_nCharId = int(_item.m_nCharId);
		obj.m_szCharName = _item.m_szCharName;
		obj.m_nLevel = int(_item.m_nLevel);
		obj.m_nRace = int(_item.m_nRace);
		obj.m_nGender = int(_item.m_nGender);
		
		var point:IntPoint = AsWingUtils.getStageMousePosition();
		FrameClickChar._objDest = obj;
		FrameClickChar._destCharId = int(obj.m_nCharId);
		FrameClickChar.show(FrameSlave._frame,point.x-FrameSlave._frame.x,point.y-FrameSlave._frame.y);
	}
	private function onBtnChallenge(e:Event):void
	{
		if(_item == null)
			return;
		Client.getInstance().sendPacketLogic(300,[int(SceneBattle.BATTLE_TYPE_PVP_ENSLAVE),_item.m_nCharId]);
		FrameSlave.hide();
	}
	//private var _tooltip:ToolTipItemCSV = new ToolTipItemCSV(0);
	private var _item:Object = null;
	public function set item(val:Object):void
	{
		
		_item = val;
		labelName.setText("");
		labelLevel.setText("");
		labelRace.setText("");
		btn_slave_catch_challenge.setVisible(false);
		panelHead.setBackgroundDecorator(null);
		if(_item == null)
		{
			return;
		}
		
		/*obj.m_nCharId = msg[nIndex++];
		obj.m_szCharName = msg[nIndex++];
		obj.m_nLevel = msg[nIndex++];
		obj.m_nRace = msg[nIndex++];
		obj.m_nGender = msg[nIndex++];
		obj.m_nValue = msg[nIndex++];*/
		labelRace.setText('种族:'+(int(_item.m_nRace) == 0 ? '人':((_item.m_nRace) == 1 ?'魔':'仙')));
		labelName.setForeground(new ASColor(_item.m_nGender == 0?Engine.colorBoy:Engine.colorGirl));
		labelName.setText(_item.m_szCharName);
		labelLevel.setText('Lv.' + _item.m_nLevel);
		btn_slave_catch_challenge.setVisible(true);
		panelHead.setBackgroundDecorator(new AssetBackground(Client.getUIElement("img_head") as DisplayObject));
		pack();
		this.paintImmediately();
		
		
	}
	public function get item():Object
	{
		return _item;
	}
	
	
}

/**
 * MyPaneSlaveMaster
 */
class PaneSlaveSlave extends JPanel{
	
	//members define
	private var panelItems:JPanel;
	private var panelRightTop:JPanel;
	public var btn_slave_tab_property:JToggleButton;
	public var btn_slave_tab_skill:JToggleButton;
	private var labelLove:JLabel;
	private var panelRight:JPanel;
	
	/**
	 * MyPaneSlaveMaster Constructor
	 */
	public var panelRightProperty:PaneSlaveSlaveProperty;
	public var panelRightSkill:PaneSlaveSlaveSkill;
	public function PaneSlaveSlave(){
		//component creation
		setSize(new IntDimension(370, 358));
		setPreferredSize(new IntDimension(370, 358));
		var layout0:EmptyLayout = new EmptyLayout();
		setLayout(layout0);
		
		panelItems = new JPanel();
		panelItems.setLocation(new IntPoint(11, 0));
		panelItems.setSize(new IntDimension(93, 351));
		panelItems.setPreferredSize(new IntDimension(93, 351));
		var layout1:FlowWrapLayout = new FlowWrapLayout();
		layout1.setPreferWidth(200);
		layout1.setAlignment(AsWingConstants.LEFT);
		layout1.setHgap(0);
		layout1.setVgap(3);
		layout1.setMargin(true);
		panelItems.setLayout(layout1);
		
		panelRightTop = new JPanel();
		panelRightTop.setLocation(new IntPoint(104, 0));
		panelRightTop.setSize(new IntDimension(266, 25));
		panelRightTop.setPreferredSize(new IntDimension(266, 25));
		var layout2:EmptyLayout = new EmptyLayout();
		panelRightTop.setLayout(layout2);
		
		btn_slave_tab_property = new JToggleButton();
		btn_slave_tab_property.setLocation(new IntPoint(20, 3));
		btn_slave_tab_property.setSize(new IntDimension(43, 22));
		btn_slave_tab_property.setPreferredSize(new IntDimension(43, 22));
		btn_slave_tab_property.setText("label");
		
		btn_slave_tab_skill = new JToggleButton();
		btn_slave_tab_skill.setLocation(new IntPoint(68, 3));
		btn_slave_tab_skill.setSize(new IntDimension(43, 22));
		btn_slave_tab_skill.setPreferredSize(new IntDimension(43, 22));
		btn_slave_tab_skill.setText("label");
		
		labelLove = new JLabel();
		labelLove.setLocation(new IntPoint(164, 5));
		labelLove.setSize(new IntDimension(89, 16));
		labelLove.setPreferredSize(new IntDimension(89, 16));
		labelLove.setText("label");
		
		//panelRight = new JPanel();
		//panelRight.setLocation(new IntPoint(104, 25));
		//panelRight.setSize(new IntDimension(266, 333));
		//panelRight.setPreferredSize(new IntDimension(266, 333));
		
		//component layoution
		append(panelItems);
		append(panelRightTop);
		//append(panelRight);
		
		panelRightTop.append(btn_slave_tab_property);
		panelRightTop.append(btn_slave_tab_skill);
		panelRightTop.append(labelLove);
		
		//private var panelRightProperty:PaneSlaveMasterProperty;
		//private var panelRightSkill:PaneSlaveMasterSkill;
		
		panelRightProperty = new PaneSlaveSlaveProperty();
		panelRightProperty.setLocation(new IntPoint(104, 25));
		panelRightProperty.setSize(new IntDimension(266, 333));
		panelRightProperty.setPreferredSize(new IntDimension(266, 333));
		
		panelRightSkill = new PaneSlaveSlaveSkill();
		panelRightSkill.setLocation(new IntPoint(104, 25));
		panelRightSkill.setSize(new IntDimension(266, 333));
		panelRightSkill.setPreferredSize(new IntDimension(266, 333));
		panelRight = panelRightProperty;
		append(panelRight);
		setImages();
		this.setClipMasked(false);
	}
	
	public function setImages():void
	{
		
		btn_slave_tab_property.setSelected(true);
		btn_slave_tab_property.wrapSimpleButton(Client.getUIElement("btn_slave_tab_property") as SimpleButton);
		btn_slave_tab_skill.wrapSimpleButton(Client.getUIElement("btn_slave_tab_skill") as SimpleButton);
		btn_slave_tab_property.setText("");
		btn_slave_tab_skill.setText("");
		var group:ButtonGroup = new ButtonGroup();
		group.appendAll(btn_slave_tab_property,btn_slave_tab_skill);
		
		for(var i:int = 0; i < 6; i++)
		{
			var item:PaneSlaveSlaveItem = new PaneSlaveSlaveItem;
			panelItems.append(item);
			_mallItems.push(item);
		}
		
		var filter:GlowFilter;
		var font:ASFont = new ASFont("宋体", 13, false, false, false, false);
		filter = new GlowFilter(0x000000, 1, 2, 2, 10);
		labelLove.setFont(font);
		labelLove.setForeground(ASColor.RED);
		labelLove.setTextFilters(new Array(filter));
		
		btn_slave_tab_property.addActionListener(onTabProperty);
		btn_slave_tab_skill.addActionListener(onTabSkill);
	}
	
	private var _mallItems:Array = new Array();
	
	public function onTabProperty(e:Event):void
	{
		if(FrameSlave._frame.getBackgroundDecorator() != FrameSlave._frame.img_slave_master_property_bg)
			FrameSlave._frame.setBackgroundDecorator(FrameSlave._frame.img_slave_master_property_bg);
			
		if(panelRight != panelRightProperty)
		{
			remove(panelRight);
			panelRight = panelRightProperty;
			append(panelRight);
		}

		paintImmediately();
	}
	public function onTabSkill(e:Event):void
	{
		if(FrameSlave._frame.getBackgroundDecorator() != FrameSlave._frame.img_slave_master_skill_bg)
			FrameSlave._frame.setBackgroundDecorator(FrameSlave._frame.img_slave_master_skill_bg);
		
		if(panelRight != panelRightSkill)
		{
			remove(panelRight);
			panelRight = panelRightSkill;
			append(panelRight);
		}
		paintImmediately();
	}
	
	public function update():void
	{
		//panelBottom.update();
		
		for each(var obj:Object in _mallItems)
		{
			obj.item = null;
		}
		if(PaneSlaveSlaveItem._selectedPetOld != null && (PaneSlaveSlaveItem._selectedPetOld.item == null || PaneSlaveSlaveItem._selectedPetOld.item.index >= CharInfo.m_arSlaves.length))
		{
			PaneSlaveSlaveItem._selectedPetOld.selected = false;
			PaneSlaveSlaveItem._selectedPetOld = null;
		}
		var nIndex:int = 0;
		for each(var item:Object in CharInfo.m_arSlaves)
		{
			_mallItems[nIndex].item = item;
			if(PaneSlaveSlaveItem._selectedPetOld == null)
				_mallItems[nIndex].selected = true;
			
			nIndex++;
		}
		
		if(PaneSlaveSlaveItem._selectedPetOld != null)
		{
			panelRightProperty.item = PaneSlaveSlaveItem._selectedPetOld.item;
			panelRightSkill.item = PaneSlaveSlaveItem._selectedPetOld.item;
		}
	}
}

/**
 * MyPaneSlaveMasterItem
 */
class PaneSlaveSlaveItem extends JPanel{
	
	//members define
	private var labelName:JLabel;
	private var labelLevel:JLabel;
	
	/**
	 * MyPaneSlaveMasterItem Constructor
	 */
	public function PaneSlaveSlaveItem(){
		//component creation
		setSize(new IntDimension(93, 47));
		setPreferredSize(new IntDimension(93, 47));
		var layout0:EmptyLayout = new EmptyLayout();
		setLayout(layout0);
		
		labelName = new JLabel();
		labelName.setLocation(new IntPoint(3, 2));
		labelName.setSize(new IntDimension(86, 20));
		labelName.setPreferredSize(new IntDimension(86, 20));
		labelName.setText("陶陶陶");
		
		labelLevel = new JLabel();
		labelLevel.setLocation(new IntPoint(3, 25));
		labelLevel.setSize(new IntDimension(86, 20));
		labelLevel.setPreferredSize(new IntDimension(86, 20));
		labelLevel.setText("Lv.55");
		
		//component layoution
		append(labelName);
		append(labelLevel);
		
		var filter:GlowFilter;
		var font:ASFont = new ASFont("宋体", 13, false, false, false, false);
		filter = new GlowFilter(0x000000, 1, 2, 2, 10);
		
		labelName.setFont(font);
		labelName.setForeground(ASColor.WHITE);
		labelName.setTextFilters(new Array(filter));
		
		labelLevel.setFont(font);
		labelLevel.setForeground(ASColor.WHITE);
		labelLevel.setTextFilters(new Array(filter));
			
		img_slave_item_selected_bg = new AssetBackground(Client.getUIElement("img_slave_item_selected_bg") as DisplayObject);
		img_slave_item_bg = new AssetBackground(Client.getUIElement("img_slave_item_bg") as DisplayObject);
		
		setBackgroundDecorator(_selected?img_slave_item_selected_bg:img_slave_item_bg);
		
		
		addEventListener(MouseEvent.CLICK, onClick);
		addEventListener(MouseEvent.ROLL_OVER, onRollOver);
		addEventListener(MouseEvent.ROLL_OUT, onRollOut);
		
		//labelName.addEventListener(MouseEvent.CLICK, onClick);
		//labelName.addEventListener(MouseEvent.ROLL_OVER, onRollOver);
		//labelName.addEventListener(MouseEvent.ROLL_OUT, onRollOut);
		
		//labelLevel.addEventListener(MouseEvent.CLICK, onClick);
		//labelLevel.addEventListener(MouseEvent.ROLL_OVER, onRollOver);
		//labelLevel.addEventListener(MouseEvent.ROLL_OUT, onRollOut);
	}
	private function onClick(event:MouseEvent):void
	{
		if(_item == null)
			return;
		if(!selected)
			selected = true;

	}
	private var _monuseOn:Boolean = false;
	private function onRollOver(event:MouseEvent):void
	{
		if(_item == null)
			return;
		
		if(!_monuseOn)
		{
			var filter:GlowFilter;
			filter = new GlowFilter(0xffff00, 1, 2, 2, 100);
			this.filters = new Array(filter);
			_monuseOn = true;
		}
	}
	
	private function onRollOut(event:MouseEvent):void
	{
		if(_item == null)
			return;
		if(_monuseOn)
		{
			this.filters = null;
			_monuseOn = false;
		}
	}
	//private var _tooltip:ToolTipItemCSV = new ToolTipItemCSV(0);
	private var _item:Object = null;
	public function set item(val:Object):void
	{

		_item = val;
		labelName.setText("");
		labelLevel.setText("");
		//setEnabled(false);
		//selected = _item != null && (FramePet._frame.selectedIndex == _item.index);
		setBackgroundDecorator(null);
		if(_item == null)
		{
			return;
		}
		setBackgroundDecorator(_selected?img_slave_item_selected_bg:img_slave_item_bg);
		//panel_pet_head.setBackgroundDecorator(new AssetBackground(Client.getUIElement("img_map_"+ _item.csv_id) as DisplayObject));
		//label_pet_name.setText(_item.name);
		//label_pet_level.setText('Lv.'+_item.m_nLevel);
		//label_pet_life.setText('资质:'+_item.growth);
		
		labelName.setText(_item.m_szCharName);
		labelLevel.setText('Lv.' + _item.m_nLevel);
		//setEnabled(true);
		pack();
		this.paintImmediately();
		
		
	}
	public function get item():Object
	{
		return _item;
	}
	
	private var img_slave_item_selected_bg:AssetBackground = null;
	private var img_slave_item_bg:AssetBackground = null;
	
	private var _selected:Boolean = false;
	public static var _selectedPetOld:PaneSlaveSlaveItem = null;
	public function set selected(val:Boolean):void
	{
		if(_selected != val)
		{
			setBackgroundDecorator(null);
			_selected = val;
			setBackgroundDecorator(_selected?img_slave_item_selected_bg:img_slave_item_bg);
			if(_selected)
			{
				FrameSlave._frame.panelBottomSlave.panelRightProperty.item = _item;
				FrameSlave._frame.panelBottomSlave.panelRightSkill.item = _item;
				FrameSlave._frame.panelBottomSlave.btn_slave_tab_property.setSelected(true);
				FrameSlave._frame.panelBottomSlave.btn_slave_tab_skill.setSelected(false);
				FrameSlave._frame.panelBottomSlave.onTabProperty(null);
				if(_selectedPetOld != null && _selectedPetOld != this)
				{
					_selectedPetOld.selected = false;
				}
				_selectedPetOld = this;
			}
		}
		if(_item == null)
		{
			setBackgroundDecorator(null);
		}
		
	}
	public function get selected():Boolean
	{
		return _selected;
	}

}

/**
 * MyPaneSlaveMasterProperty
 */
class PaneSlaveSlaveProperty extends JPanel{
	
	//members define
	private var panelImage:JPanel;
	private var labelName:JLabelButton;
	private var labelHP:JLabel;
	private var labelAP:JLabel;
	private var labelDP:JLabel;
	private var labelSP:JLabel;
	private var labelResistHL:JLabel;
	private var labelResistBD:JLabel;
	private var labelResistHS:JLabel;
	private var labelPropBJ:JLabel;
	private var labelPropSB:JLabel;
	private var labelPropFJ:JLabel;
	private var labelPropLJ:JLabel;
	private var panel128:JPanel;
	private var btn_slave_master_dl:JButton;
	private var btn_slave_master_bd:JButton;
	private var btn_slave_master_ws:JButton;
	private var btn_slave_master_jj:JButton;
	private var btn_slave_master_af:JButton;
	private var btn_slave_master_zs:JButton;
	private var btn_slave_master_pj:JButton;
	private var btn_slave_master_free:JButton;
	private var btn_slave_master_setting:JButton;
	private var btn_slave_master_battle:JButton;
	
	/**
	 * MyPaneSlaveMasterProperty Constructor
	 */
	public function PaneSlaveSlaveProperty(){
		//component creation
		setSize(new IntDimension(266, 333));
		setPreferredSize(new IntDimension(266, 333));
		var layout0:EmptyLayout = new EmptyLayout();
		setLayout(layout0);
		
		panelImage = new JPanel();
		panelImage.setLocation(new IntPoint(3, 6));
		panelImage.setSize(new IntDimension(114, 200));
		panelImage.setPreferredSize(new IntDimension(114, 200));
		var layout1:EmptyLayout = new EmptyLayout();
		panelImage.setLayout(layout1);
		
		labelName = new JLabelButton();
		labelName.setLocation(new IntPoint(0, 0));
		labelName.setSize(new IntDimension(114, 20));
		labelName.setPreferredSize(new IntDimension(114, 20));
		labelName.setText("label");
		
		labelHP = new JLabel();
		labelHP.setLocation(new IntPoint(164, 6));
		labelHP.setSize(new IntDimension(89, 16));
		labelHP.setPreferredSize(new IntDimension(89, 16));
		labelHP.setText("label");
		
		labelAP = new JLabel();
		labelAP.setLocation(new IntPoint(164, 32));
		labelAP.setSize(new IntDimension(89, 16));
		labelAP.setPreferredSize(new IntDimension(89, 16));
		labelAP.setText("label");
		
		labelDP = new JLabel();
		labelDP.setLocation(new IntPoint(164, 58));
		labelDP.setSize(new IntDimension(89, 16));
		labelDP.setPreferredSize(new IntDimension(89, 16));
		labelDP.setText("label");
		
		labelSP = new JLabel();
		labelSP.setLocation(new IntPoint(164, 84));
		labelSP.setSize(new IntDimension(89, 16));
		labelSP.setPreferredSize(new IntDimension(89, 16));
		labelSP.setText("label");
		
		labelResistHL = new JLabel();
		labelResistHL.setLocation(new IntPoint(164, 119));
		labelResistHL.setSize(new IntDimension(89, 16));
		labelResistHL.setPreferredSize(new IntDimension(89, 16));
		labelResistHL.setText("label");
		
		labelResistBD = new JLabel();
		labelResistBD.setLocation(new IntPoint(164, 145));
		labelResistBD.setSize(new IntDimension(89, 16));
		labelResistBD.setPreferredSize(new IntDimension(89, 16));
		labelResistBD.setText("label");
		
		labelResistHS = new JLabel();
		labelResistHS.setLocation(new IntPoint(164, 170));
		labelResistHS.setSize(new IntDimension(89, 16));
		labelResistHS.setPreferredSize(new IntDimension(89, 16));
		labelResistHS.setText("label");
		
		labelPropBJ = new JLabel();
		labelPropBJ.setLocation(new IntPoint(44, 212));
		labelPropBJ.setSize(new IntDimension(82, 16));
		labelPropBJ.setPreferredSize(new IntDimension(82, 16));
		labelPropBJ.setText("label");
		
		labelPropSB = new JLabel();
		labelPropSB.setLocation(new IntPoint(171, 212));
		labelPropSB.setSize(new IntDimension(82, 16));
		labelPropSB.setPreferredSize(new IntDimension(82, 16));
		labelPropSB.setText("label");
		
		labelPropFJ = new JLabel();
		labelPropFJ.setLocation(new IntPoint(44, 237));
		labelPropFJ.setSize(new IntDimension(82, 16));
		labelPropFJ.setPreferredSize(new IntDimension(82, 16));
		labelPropFJ.setText("label");
		
		labelPropLJ = new JLabel();
		labelPropLJ.setLocation(new IntPoint(171, 237));
		labelPropLJ.setSize(new IntDimension(82, 16));
		labelPropLJ.setPreferredSize(new IntDimension(82, 16));
		labelPropLJ.setText("label");
		
		panel128 = new JPanel();
		panel128.setLocation(new IntPoint(3, 266));
		panel128.setSize(new IntDimension(252, 51));
		panel128.setPreferredSize(new IntDimension(252, 51));
		var layout2:GridLayout = new GridLayout();
		layout2.setRows(2);
		layout2.setColumns(5);
		layout2.setHgap(3);
		layout2.setVgap(3);
		panel128.setLayout(layout2);
		
		btn_slave_master_dl = new JButton();
		btn_slave_master_dl.setSize(new IntDimension(48, 24));
		btn_slave_master_dl.setToolTipText("滴蜡");
		btn_slave_master_dl.setText("滴蜡");
		
		btn_slave_master_bd = new JButton();
		btn_slave_master_bd.setLocation(new IntPoint(0, 27));
		btn_slave_master_bd.setSize(new IntDimension(252, 24));
		btn_slave_master_bd.setToolTipText("鞭打");
		btn_slave_master_bd.setText("鞭打");
		
		btn_slave_master_ws = new JButton();
		btn_slave_master_ws.setLocation(new IntPoint(0, 27));
		btn_slave_master_ws.setSize(new IntDimension(124, 24));
		btn_slave_master_ws.setToolTipText("喂食");
		btn_slave_master_ws.setText("喂食");
		
		btn_slave_master_jj = new JButton();
		btn_slave_master_jj.setLocation(new IntPoint(127, 27));
		btn_slave_master_jj.setSize(new IntDimension(124, 24));
		btn_slave_master_jj.setToolTipText("敬酒");
		btn_slave_master_jj.setText("敬酒");
		
		btn_slave_master_af = new JButton();
		btn_slave_master_af.setLocation(new IntPoint(85, 27));
		btn_slave_master_af.setSize(new IntDimension(82, 24));
		btn_slave_master_af.setToolTipText("爱抚");
		btn_slave_master_af.setText("爱抚");
		
		btn_slave_master_zs = new JButton();
		btn_slave_master_zs.setLocation(new IntPoint(170, 27));
		btn_slave_master_zs.setSize(new IntDimension(82, 24));
		btn_slave_master_zs.setToolTipText("征收");
		btn_slave_master_zs.setText("征收");
		
		btn_slave_master_pj = new JButton();
		btn_slave_master_pj.setLocation(new IntPoint(126, 27));
		btn_slave_master_pj.setSize(new IntDimension(60, 24));
		btn_slave_master_pj.setToolTipText("评价");
		btn_slave_master_pj.setText("评价");
		
		btn_slave_master_free = new JButton();
		btn_slave_master_free.setLocation(new IntPoint(102, 27));
		btn_slave_master_free.setSize(new IntDimension(48, 24));
		btn_slave_master_free.setToolTipText("释放");
		btn_slave_master_free.setText("释放");
		
		btn_slave_master_setting = new JButton();
		btn_slave_master_setting.setLocation(new IntPoint(189, 27));
		btn_slave_master_setting.setSize(new IntDimension(60, 24));
		btn_slave_master_setting.setToolTipText("设置");
		btn_slave_master_setting.setText("设置");
		
		btn_slave_master_battle = new JButton();
		btn_slave_master_battle.setLocation(new IntPoint(153, 27));
		btn_slave_master_battle.setSize(new IntDimension(48, 24));
		btn_slave_master_battle.setToolTipText("参战");
		btn_slave_master_battle.setText("参战");
		
		//component layoution
		append(panelImage);
		append(labelHP);
		append(labelAP);
		append(labelDP);
		append(labelSP);
		append(labelResistHL);
		append(labelResistBD);
		append(labelResistHS);
		append(labelPropBJ);
		append(labelPropSB);
		append(labelPropFJ);
		append(labelPropLJ);
		append(panel128);
		
		panelImage.append(labelName);
		
		panel128.append(btn_slave_master_dl);
		panel128.append(btn_slave_master_bd);
		panel128.append(btn_slave_master_ws);
		panel128.append(btn_slave_master_jj);
		panel128.append(btn_slave_master_af);
		panel128.append(btn_slave_master_zs);
		panel128.append(btn_slave_master_pj);
		panel128.append(btn_slave_master_free);
		panel128.append(btn_slave_master_setting);
		panel128.append(btn_slave_master_battle);
		
		//component layoution
		
		btn_slave_master_dl.wrapSimpleButton(Client.getUIElement("btn_2") as SimpleButton);
		btn_slave_master_dl.setText("滴蜡");
		btn_slave_master_bd.wrapSimpleButton(Client.getUIElement("btn_2") as SimpleButton);
		btn_slave_master_bd.setText("鞭打");
		btn_slave_master_ws.wrapSimpleButton(Client.getUIElement("btn_2") as SimpleButton);
		btn_slave_master_ws.setText("喂食");
		btn_slave_master_jj.wrapSimpleButton(Client.getUIElement("btn_2") as SimpleButton);
		btn_slave_master_jj.setText("敬酒");
		btn_slave_master_af.wrapSimpleButton(Client.getUIElement("btn_2") as SimpleButton);
		btn_slave_master_af.setText("爱抚");
		btn_slave_master_zs.wrapSimpleButton(Client.getUIElement("btn_2") as SimpleButton);
		btn_slave_master_zs.setText("征收");
		btn_slave_master_pj.wrapSimpleButton(Client.getUIElement("btn_2") as SimpleButton);
		btn_slave_master_pj.setText("评价");
		btn_slave_master_setting.wrapSimpleButton(Client.getUIElement("btn_2") as SimpleButton);
		btn_slave_master_setting.setText("设置");

		btn_slave_master_battle.wrapSimpleButton(Client.getUIElement("btn_2") as SimpleButton);
		btn_slave_master_battle.setText("参战");
		btn_slave_master_free.wrapSimpleButton(Client.getUIElement("btn_2") as SimpleButton);
		btn_slave_master_free.setText("释放");
		
		var filter:GlowFilter;
		var font:ASFont = new ASFont("宋体", 12, false, false, false, false);
		filter = new GlowFilter(0x000000, 1, 2, 2, 5);
		labelDP.setFont(font);
		labelDP.setForeground(ASColor.WHITE);
		labelDP.setTextFilters(new Array(filter));
		labelHP.setFont(font);
		labelHP.setForeground(ASColor.WHITE);
		labelHP.setTextFilters(new Array(filter));
		labelAP.setFont(font);
		labelAP.setForeground(ASColor.WHITE);
		labelAP.setTextFilters(new Array(filter));
		labelPropBJ.setFont(font);
		labelPropBJ.setForeground(ASColor.WHITE);
		labelPropBJ.setTextFilters(new Array(filter));
		labelPropSB.setFont(font);
		labelPropSB.setForeground(ASColor.WHITE);
		labelPropSB.setTextFilters(new Array(filter));
		labelPropFJ.setFont(font);
		labelPropFJ.setForeground(ASColor.WHITE);
		labelPropFJ.setTextFilters(new Array(filter));
		labelPropLJ.setFont(font);
		labelPropLJ.setForeground(ASColor.WHITE);
		labelPropLJ.setTextFilters(new Array(filter));
		labelSP.setFont(font);
		labelSP.setForeground(ASColor.WHITE);
		labelSP.setTextFilters(new Array(filter));
		labelResistHL.setFont(font);
		labelResistHL.setForeground(ASColor.WHITE);
		labelResistHL.setTextFilters(new Array(filter));
		labelResistBD.setFont(font);
		labelResistBD.setForeground(ASColor.WHITE);
		labelResistBD.setTextFilters(new Array(filter));
		labelResistHS.setFont(font);
		labelResistHS.setForeground(ASColor.WHITE);
		labelResistHS.setTextFilters(new Array(filter));
		
		btn_slave_master_battle.addActionListener(onBtnBattle);
		btn_slave_master_free.addActionListener(onBtnFree);
		btn_slave_master_setting.addActionListener(onBtnBattleSetting);
		
		font = new ASFont("宋体", 13, false, false, false, false);
		btn_slave_master_battle.setFont(font);
		btn_slave_master_battle.setForeground(ASColor.WHITE);
		btn_slave_master_battle.setTextFilters(new Array(filter));
		
		btn_slave_master_dl.setFont(font);
		btn_slave_master_dl.setForeground(ASColor.WHITE);
		btn_slave_master_dl.setTextFilters(new Array(filter));
		
		btn_slave_master_bd.setFont(font);
		btn_slave_master_bd.setForeground(ASColor.WHITE);
		btn_slave_master_bd.setTextFilters(new Array(filter));
		
		btn_slave_master_ws.setFont(font);
		btn_slave_master_ws.setForeground(ASColor.WHITE);
		btn_slave_master_ws.setTextFilters(new Array(filter));
		
		btn_slave_master_jj.setFont(font);
		btn_slave_master_jj.setForeground(ASColor.WHITE);
		btn_slave_master_jj.setTextFilters(new Array(filter));
		
		btn_slave_master_af.setFont(font);
		btn_slave_master_af.setForeground(ASColor.WHITE);
		btn_slave_master_af.setTextFilters(new Array(filter));
		
		btn_slave_master_zs.setFont(font);
		btn_slave_master_zs.setForeground(ASColor.WHITE);
		btn_slave_master_zs.setTextFilters(new Array(filter));
		
		btn_slave_master_pj.setFont(font);
		btn_slave_master_pj.setForeground(ASColor.WHITE);
		btn_slave_master_pj.setTextFilters(new Array(filter));
		
		btn_slave_master_free.setFont(font);
		btn_slave_master_free.setForeground(ASColor.WHITE);
		btn_slave_master_free.setTextFilters(new Array(filter));
		
		btn_slave_master_setting.setFont(font);
		btn_slave_master_setting.setForeground(ASColor.WHITE);
		btn_slave_master_setting.setTextFilters(new Array(filter));
		
		btn_slave_master_dl.setEnabled(false);
		btn_slave_master_bd.setEnabled(false);
		btn_slave_master_ws.setEnabled(false);
		btn_slave_master_jj.setEnabled(false);
		btn_slave_master_af.setEnabled(false);
		btn_slave_master_zs.setEnabled(false);
		btn_slave_master_pj.setEnabled(false);
		btn_slave_master_setting.setEnabled(false);

		btn_slave_master_free.setEnabled(false);
		//btn_slave_master_battle.setEnabled(false);
		
		labelName.setForeground(ASColor.WHITE);
		labelName.setFont(new ASFont("宋体", 12, false, false, true, false));
		labelName.setTextFilters( new Array(filter));
		labelName.addActionListener(onBtnName);
		//setClipMasked(false);
		panelImage.setClipMasked(false);
	}
	
	private function onBtnBattleSetting(e:Event):void
	{
		FrameBattleSetting.show(FrameSlave._frame,FrameBattleSetting.BATTLE_SETTING_TYPE_SLAVE);
	}
	private function onBtnBattle(e:Event):void
	{
		var bInBattle:Boolean = !(_item.index != CharInfo.m_nSlaveJoinBattleIndex || CharInfo.m_nBattlePartnerType != PanelMain.PARTNER_TYPE_SLAVE);
		Client.getInstance().sendPacketLogic(1501,[int(!bInBattle?1:0),int(_item.index)]);
	}
	
	//private function onBtnFree(e:Event):void
	//{
		//Client.getInstance().sendPacketLogic(1502,[int(_item.id),int(_item.index)]);
		private function onBtnFree(e:Event):void
		{
			var pane:FrameInfo = FrameInfo.showMessageDialog("","是否将奴隶 "+_item.m_szCharName +" 释放?",handleOptionFree,null,true,null,JOptionPane.YES|JOptionPane.NO);
		}
		
		private function onBtnName(e:Event):void
		{
			if(_item == null)
				return;
			
			var obj:Object = new Object;
			obj.m_nCharId = int(_item.m_nCharId);
			obj.m_szCharName = _item.m_szCharName;
			obj.m_nLevel = int(_item.m_nLevel);
			obj.m_nRace = int(_item.m_nRace);
			obj.m_nGender = int(_item.m_nGender);
			
			var point:IntPoint = AsWingUtils.getStageMousePosition();
			FrameClickChar._objDest = obj;
			FrameClickChar._destCharId = int(obj.m_nCharId);
			FrameClickChar.show(FrameSlave._frame,point.x-FrameSlave._frame.x,point.y-FrameSlave._frame.y);
		}
		private function handleOptionFree(button:uint):void
		{
			if(button == JOptionPane.YES)
			{
					//Client.getInstance().sendPacketLogic(104,[selectedIndex,CharInfo.m_arPets[selectedIndex].id]);
				Client.getInstance().sendPacketLogic(1502,[int(_item.id),int(_item.index)]);
			}
		}
	
	//_________getters_________
	//private var _tooltip:ToolTipItemCSV = new ToolTipItemCSV(0);
	private var _item:Object = null;
	public function set item(val:Object):void
	{
		
		_item = val;
		panelImage.setBackgroundDecorator(null);
		labelHP.setText("");
		labelAP.setText("");
		labelDP.setText("");
		labelSP.setText("");
		
		labelResistHL.setText("");
		labelResistBD.setText("");
		labelResistHS.setText("");
		
		labelPropBJ.setText("");
		labelPropSB.setText("");
		labelPropFJ.setText("");
		labelPropLJ.setText("");
		
		btn_slave_master_free.setEnabled(false);
		btn_slave_master_setting.setEnabled(false);
		btn_slave_master_battle.setEnabled(false);
		
		var imgSelf:Container = panelImage;
		if(_mcSlaveImage != null && imgSelf.contains(_mcSlaveImage))
		{
			imgSelf.removeChild(_mcSlaveImage)
		}
		
		if(_item == null)
		{
			return;
		}
		
		if(_item.m_nGender == 0)
			labelName.setForeground(new ASColor(Engine.colorBoy));
		if(_item.m_nGender == 1)
			labelName.setForeground(new ASColor(Engine.colorGirl));
		labelName.setText(_item.m_szCharName + ' Lv.' + _item.m_nLevel);
		btn_slave_master_free.setEnabled(true);
		btn_slave_master_setting.setEnabled(true);
		btn_slave_master_battle.setEnabled(true);
		var bInBattle:Boolean = !(_item.index != CharInfo.m_nSlaveJoinBattleIndex || CharInfo.m_nBattlePartnerType != PanelMain.PARTNER_TYPE_SLAVE);
		//btn_slave_master_battle.setEnabled(!bInBattle);
		btn_slave_master_battle.setText(!bInBattle?"参战":"休战");
		
		labelHP.setText(_item.m_nHP);
		labelAP.setText(_item.m_nAP);
		labelDP.setText(_item.m_nDP);
		labelSP.setText(_item.m_nSP);
		
		labelResistHL.setText(_item.m_nResistHL);
		labelResistBD.setText(_item.m_nResistBD);
		labelResistHS.setText(_item.m_nResistHS);
		
		labelPropBJ.setText(_item.m_nPropBJ);
		labelPropSB.setText(_item.m_nPropSB);
		labelPropFJ.setText(_item.m_nPropFJ);
		labelPropLJ.setText(_item.m_nPropLJ);
		updateSlaveImage();
		pack();
		this.paintImmediately();
		
		
	}
	public function get item():Object
	{
		return _item;
	}
	
	private var _loaderSlave:CharImageLoader = null;
	public function updateSlaveImage():void
	{
		if(_loaderSlave == null)
			_loaderSlave = new CharImageLoader;
		if(_item.m_nCharId == 0)
			return;
		if(_mcSlaveImage != null && !panelImage.contains(_mcSlaveImage))
			panelImage.addChildAt(_mcSlaveImage,0);
		_loaderSlave.loadChar(_item.m_nRace,_item.m_nGender,_item.m_arEquips,onSlaveLoaded);
	}
	private var _mcSlaveImage:MovieClip = null;
	private function onSlaveLoaded():void
	{
		
		var imgSelf:Container = panelImage;
		if(_mcSlaveImage != null && imgSelf.contains(_mcSlaveImage))
		{
			imgSelf.removeChild(_mcSlaveImage)
			_mcSlaveImage = null;
		}
		_mcSlaveImage = _loaderSlave.getImage("mc_object_stand",true);
		var mc:MovieClip = _mcSlaveImage;
		if(mc == null)
			return;
		//mc.gotoAndStop(0);
		mc.scaleX = 1.0;
		mc.scaleY = 1.0;
		mc.x = (imgSelf.width - mc.width)/2;
		mc.y = (imgSelf.height - mc.height);
		//if(CharInfo.objLover.m_nGender == 0)
		//	mc.y += Client._headOffsetYBoy*mc.scaleY;
		//else
		//	mc.y += Client._headOffsetYGirl*mc.scaleY;
		imgSelf.setBackgroundDecorator(null);
		imgSelf.addChildAt(mc,0);
		//mc.scaleX = -1.0;
		//mc.x = mc.x*mc.scaleX +imgSelf.width;
		//mc.x = x;
		//panelImageLover.scaleX = -1;
		//if(mc.stage != null)
		//mc.stage.frameRate = 10;
		
		//_loaderSlave.clear();
		//_loaderSlave = null;
		
	}
}


/**
 * MyPaneSlaveMasterSkill
 */
class PaneSlaveSlaveSkill extends JPanel{
	
	//members define
	//members define
	private var panelItems:JPanel;
	private var panel117:JPanel;
	private var btnPrev:JButton;
	private var labelPage:JLabel;
	private var btnNext:JButton;
	/**
	 * MyPaneSlaveMasterSkill Constructor
	 */
	public function PaneSlaveSlaveSkill(){
		//component creation
		setSize(new IntDimension(266, 333));
		setPreferredSize(new IntDimension(266, 333));
		var layout0:EmptyLayout = new EmptyLayout();
		setLayout(layout0);
		
		panelItems = new JPanel();
		panelItems.setLocation(new IntPoint(0, 25));
		panelItems.setSize(new IntDimension(256, 270));
		panelItems.setPreferredSize(new IntDimension(256, 270));
		var layout1:GridLayout = new GridLayout();
		layout1.setRows(6);
		layout1.setColumns(1);
		layout1.setHgap(0);
		layout1.setVgap(0);
		panelItems.setLayout(layout1);
		
		panel117 = new JPanel();
		panel117.setLocation(new IntPoint(0, 298));
		panel117.setSize(new IntDimension(266, 24));
		panel117.setPreferredSize(new IntDimension(266, 24));
		var layout2:EmptyLayout = new EmptyLayout();
		panel117.setLayout(layout2);
		
		btnPrev = new JButton();
		btnPrev.setLocation(new IntPoint(77, 0));
		btnPrev.setSize(new IntDimension(29, 24));
		btnPrev.setPreferredSize(new IntDimension(29, 24));
		btnPrev.setText("label");
		
		labelPage = new JLabel();
		labelPage.setLocation(new IntPoint(116, 4));
		labelPage.setSize(new IntDimension(36, 16));
		labelPage.setPreferredSize(new IntDimension(36, 16));
		labelPage.setText("label");
		
		btnNext = new JButton();
		btnNext.setLocation(new IntPoint(162, 0));
		btnNext.setSize(new IntDimension(29, 24));
		btnNext.setPreferredSize(new IntDimension(29, 24));
		btnNext.setText("label");
		
		//component layoution
		append(panelItems);
		append(panel117);
		
		panel117.append(btnPrev);
		panel117.append(labelPage);
		panel117.append(btnNext);
		
		//component layoution
		setImages();
	}
	
	public function setImages():void
	{
		
		
		btnPrev.setText("");
		btnNext.setText("");
		
		btnPrev.wrapSimpleButton(Client.getUIElement("btn_prev") as SimpleButton);
		btnNext.wrapSimpleButton(Client.getUIElement("btn_next") as SimpleButton);
		
		btnPrev.addActionListener(onBtnPrev);
		btnNext.addActionListener(onBtnNext);
		
		var filter:GlowFilter;
		var font:ASFont = new ASFont("宋体", 12, false, false, false, false);
		filter = new GlowFilter(0x000000, 1, 2, 2, 10);
		labelPage.setForeground(ASColor.WHITE);
		labelPage.setFont(font);
		labelPage.setTextFilters(new Array(filter));
		
		for(var i:int = 0; i < 6; i++)
		{
			var item:PaneSlaveSlaveSkillItem = new PaneSlaveSlaveSkillItem;
			panelItems.append(item);
			_mallItems.push(item);
		}
		
	}
	
	private var _mallItems:Array = new Array();
	
	//_________getters_________
	
	private var _currentPageIndex:int = 0;
	private var _currentPageIndexAll:int = 0;
	private var _itemsPerPage:int = 6;
	public function updatePage():void
	{
		
		var objects:Array = _item == null ? null : _item.m_arSkills;
		
		for each(var obj:Object in _mallItems)
		{
			obj.item = null;
		}
		
		if(objects == null)
			return;
		var nIndex:int = 0;
		var nCount:int = 0;
		for each(var item:Object in objects)
		{
			nCount++;
			if(nCount <= _currentPageIndex*_itemsPerPage)
				continue;
			_mallItems[nIndex++].item = item;
			if(nIndex >= _itemsPerPage)
				break;
		}
		
		var nCount1:int = objects.length;
		_currentPageIndexAll = Math.floor((nCount1+_itemsPerPage-1)/_itemsPerPage);
		labelPage.setText(_currentPageIndex+1+'/'+_currentPageIndexAll);
		btnPrev.setEnabled(_currentPageIndex > 0 &&  _currentPageIndexAll > 1);
		btnNext.setEnabled(_currentPageIndex < _currentPageIndexAll-1 &&  _currentPageIndexAll > 1);
	}
	
	private function onBtnPrev(event:Event):void
	{
		_currentPageIndex--;
		if(_currentPageIndex < 0)
			_currentPageIndex = 0;
		else
			updatePage();
		labelPage.setText(_currentPageIndex+1+'/'+_currentPageIndexAll);
	}
	private function onBtnNext(event:Event):void
	{
		_currentPageIndex++;
		if(_currentPageIndex > _currentPageIndexAll-1)
			_currentPageIndex = _currentPageIndexAll-1;
		else
			updatePage();
		labelPage.setText(_currentPageIndex+1+'/'+_currentPageIndexAll);
	}
	
	private var _item:Object = null;
	public function set item(val:Object):void
	{
		
		_item = val;
		updatePage();
		//if(_item == null)
		//{
		//	return;
		//}
		//updatePage();
		pack();
		this.paintImmediately();
		
		
	}
	public function get item():Object
	{
		return _item;
	}
}
/**
 * MyPaneSlaveMasterSkillItem
 */
class PaneSlaveSlaveSkillItem extends JPanel{
	
	//members define
	private var panelIcon:PanelSkill;
	private var labelName:JLabel;
	private var labelLevel:JLabel;
	private var labelTargetCount:JLabel;
	private var labelLove:JLabel;
	
	/**
	 * MyPaneSlaveMasterSkillItem Constructor
	 */
	
	private var objSkillCSV:Object = null;
	//private var skill:PanelSkill = null;
	//private var tooltip:ToolTipSkill = null;
	
	public function PaneSlaveSlaveSkillItem(){
		//component creation
		setSize(new IntDimension(256, 45));
		setPreferredSize(new IntDimension(256, 45));
		var layout0:EmptyLayout = new EmptyLayout();
		setLayout(layout0);
		
		panelIcon = new PanelSkill();
		panelIcon.setLocation(new IntPoint(2, 3));
		panelIcon.setSize(new IntDimension(40, 40));
		panelIcon.setPreferredSize(new IntDimension(40, 40));
		
		labelName = new JLabel();
		labelName.setLocation(new IntPoint(40, 14));
		labelName.setSize(new IntDimension(73, 16));
		labelName.setPreferredSize(new IntDimension(73, 16));
		labelName.setText("label");
		
		labelLevel = new JLabel();
		labelLevel.setLocation(new IntPoint(114, 14));
		labelLevel.setSize(new IntDimension(35, 16));
		labelLevel.setPreferredSize(new IntDimension(35, 16));
		labelLevel.setText("label");
		
		labelTargetCount = new JLabel();
		labelTargetCount.setLocation(new IntPoint(150, 14));
		labelTargetCount.setSize(new IntDimension(45, 16));
		labelTargetCount.setPreferredSize(new IntDimension(45, 16));
		labelTargetCount.setText("label");
		
		labelLove = new JLabel();
		labelLove.setLocation(new IntPoint(196, 14));
		labelLove.setSize(new IntDimension(60, 16));
		labelLove.setPreferredSize(new IntDimension(60, 16));
		labelLove.setText("label");
		
		//component layoution
		append(panelIcon);
		append(labelName);
		append(labelLevel);
		append(labelTargetCount);
		append(labelLove);
		
		
		var filter:GlowFilter;
		var font:ASFont = new ASFont("宋体", 13, false, false, false, false);
		filter = new GlowFilter(0x000000, 1, 2, 2, 10);
		labelName.setForeground(ASColor.WHITE);
		labelName.setFont(font);
		labelName.setTextFilters(new Array(filter));
		
		labelLevel.setForeground(ASColor.WHITE);
		labelLevel.setFont(font);
		labelLevel.setTextFilters(new Array(filter));
		
		labelTargetCount.setForeground(ASColor.WHITE);
		labelTargetCount.setFont(font);
		labelTargetCount.setTextFilters(new Array(filter));
		
		labelLove.setForeground(ASColor.WHITE);
		labelLove.setFont(font);
		labelLove.setTextFilters(new Array(filter));
		
	}
	
	//_________getters_________
	
	private var _item:Object = null;
	public function set item(val:Object):void
	{
		
		_item = val;
		//panelIcon.setBackgroundDecorator(null);
		
		//if(tooltip != null)
		//	tooltip.setTargetComponent(null);
		
		labelName.setText("");
		labelLevel.setText("");
		labelTargetCount.setText("");
		labelLove.setText("");
		
		if(item != null && item.csv_id != 0)
		{
			objSkillCSV = Client.getInstance().GetSkillCSV(item.csv_id);
			//panelIcon.icon_id = objSkillCSV.icon_id;
			labelName.setText(objSkillCSV.name);
			labelLevel.setText(item.m_nLevel);
			labelTargetCount.setText(item.m_nLevel);
			//if(tooltip == null)
			//	tooltip = new ToolTipSkill(item);
			//else
			//	tooltip.setItem(item);
			//tooltip.setTargetComponent(panelIcon);
		}
		//else
		//{
		//	panelIcon.icon_id = 0;
		//	if(tooltip != null)
		//		tooltip.setTargetComponent(null);
		//}
		//updateIcon(panelIcon);
		panelIcon.item = item;
	}
	/*private function updateIcon(panel:PanelSkill):void
	{ 
		if(panel.icon_id <= 0)
		{
			panel.setBackgroundDecorator(null);
			return;
		}
		panel.setBackgroundDecorator(new AssetBackground(Client.getSkillElement("img_skill_"+panel.icon_id) as DisplayObject));
	}*/
	public function get item():Object
	{
		return _item;
	}
	public function clear():void
	{
		setBackgroundDecorator(null);
		panelIcon.setBackgroundDecorator(null);
		item = null;
	}
	
	
	
	
	
}

//import src.*;


/*class DraggingImageSkill implements DraggingImage
{
	private var initiator:PanelSkill;
	
	public function DraggingImageSkill(dragInitiator : PanelSkill)
	{
		initiator = new PanelSkill();
		initiator.height = dragInitiator.height;
		initiator.width = dragInitiator.width;
		initiator.setLocationXY(0,0);
		initiator.setBackgroundDecorator(new AssetBackground(Client.getSkillElement("img_skill_"+dragInitiator.icon_id) as DisplayObject));
	}
	
	public function getDisplay():DisplayObject
	{
		return initiator;
	}
	
	public function switchToAcceptImage() : void 
	{
		
		var filter:GlowFilter;
		filter = new GlowFilter(0x00ff00, 1, 2, 2, 10);
		initiator.filters = new Array(filter);
	}
	
	public function switchToRejectImage() : void 
	{
		var filter:GlowFilter;
		filter = new GlowFilter(0xff0000, 1, 2, 2, 10);
		initiator.filters = new Array(filter);
	}
	
}

class PanelSkill extends JPanel
{
	public var icon_id:uint = 0;
	public var index:uint = 0;
	public function PanelSkill()
	{
	}
	public function clear():void
	{
		setBackgroundDecorator(null);
	}
}*/